<template>
  <div class="padding_10">
    <div id="printTest">
      <div>
        <el-descriptions title="采购信息">
          <el-descriptions-item label="供应商">
            {{ tableData.supplier_name }}
          </el-descriptions-item>
          <el-descriptions-item label="经手人">
            {{ tableData.user_name }}
          </el-descriptions-item>

          <el-descriptions-item label="备注">
            {{ tableData.remark }}
          </el-descriptions-item>
        </el-descriptions>
      </div>
      <el-table :data="tableData.item" style="width: 100%">
        <el-table-column label="商品批号" prop="batch_sn" />
        <el-table-column label="商品名称" prop="goods_name" />
        <el-table-column label="商品数量" prop="qty" />
        <el-table-column label="商品价格" prop="supply_price" />
        <el-table-column label="商品开始日期" prop="start_at" />
        <el-table-column label="商品结束日期" prop="expire_at" />
      </el-table>
    </div>
    <div style="margin-top: 30px; text-align: center">
      <el-button @click="goBack">返回</el-button>
      <el-button v-print="'#printTest'" type="primary" @click="Print">
        打印
      </el-button>
    </div>
  </div>
</template>

<script>
  import { goodsInDetail } from '@/api/commodity'
  export default {
    props: {
      id: {
        type: Number,
        required: true,
      },
    },
    data() {
      return {
        tableData: {},
      }
    },
    watch: {},

    mounted() {
      this.init()
    },
    methods: {
      // 初始化 方法
      init() {
        const parmas = {
          id: this.id,
        }
        goodsInDetail(parmas).then((e) => {
          this.tableData = e.data
        })
      },

      // 返回
      goBack() {
        this.$emit('showMain', 0)
      },
      Print() {},
    },
  }
</script>

<style></style>
